Skip to content

fix(server): recall skips a saved fact the message already states - #140

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
t3/project-memory-skip-restated-facts-2
Nov 17, 2026
Merged

ScriptedAlchemy merged 3 commits into
mainfrom
t3/project-memory-skip-restated-facts-2

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Recall attaches up to two saved facts at turn start. In the blind judging of #135's deliveries, about 28% of attached facts only repeated what the message already said. Almost all of these were on agent-written briefs. Coverage scoring ranks such facts highest, so they took a slot another fact could have used.

Fix. A fact stops being eligible when the message already states it, judged by word order rather than vocabulary. The check takes runs of four consecutive content terms (the same terms the gate already uses). If at least 10% of the fact's runs appear in the message, the fact is skipped and the next match takes its slot. Shared names and scattered vocabulary do not count: a 2–3 word name gives at most one run, and a long brief that contains every word of a fact out of order shares none. This is one rule with one threshold, in rankRecallCandidates, and adds no migration.

Proof

  • I split the 298 judged pairs by sha256(pairId) % 2, chose the rule on one half (160 pairs), and scored it once on the other (138). Before scoring, I set the bar at: ≥50% of both-agree restates removed, ≤2 useful removed by either judge, and 0 both-agree useful removed.

    Held-out half judge A judge B both agree
    restates removed 12/25 13/24 10/19 (53%)
    useful removed 0/30 0/45 0/28

    On the dev half: 20/33 both-agree restatements removed, 0 useful removed.

  • Limit: it clears the bar only narrowly, and only for verbatim pastes. Pairs repeat facts across briefs. All removals in the judged set come from 4 distinct facts, mostly lines that a recurring review-brief template pastes in. The rule catches 2 of the 21 distinct facts the judges called restatements. Held-out pairs whose fact never appears in the dev half: 0/5 removed. Paraphrased restatements remain. Every broader lexical rule I tried also removed useful facts. For example, fact coverage ≥0.6 catches 8 of 21 facts but removes 3 pairs both judges called useful.

  • Replay (the fix(server): project memory recall matches the whole message and skips progress notices #135 harness, 1,036 messages and 771 facts, 3 interleaved runs per side; deliveries were identical in every run):

    class before after
    brief 472 452
    person 14 14
    watch 20 20

    78 brief deliveries were removed. Of the 36 that had been judged: 27 both restates, 5 one-judge restates, 4 related/off-topic, 0 useful. In 58 cases the next-ranked fact took the freed slot, and 7 briefs were left with no attachment. Nobody has judged those 58 replacements. On my own unblinded read, about half name the brief's own subject. 8 are a paraphrase of the same review-template instruction, which this rule cannot see. About 16 are generic process facts (one appears 10 times), and the rest are loosely related or off-topic.

  • Cost. Building the message's run set once per lookup adds about 0.15 ms. A fact's runs are only built after it has passed every other check. Scoring 100 candidates against an 8,192-char brief went from 0.93 to 1.10 ms (4×200 lookups). Replay latency stayed within run-to-run spread: p50 10.2–11.1 ms after vs 10.3–15.0 ms before, with no timeouts against the 1 s budget.

  • A new recallRelevance row shows a stated fact giving up its slot and a fact that shares the brief's vocabulary still attaching. It failed before the fix. Ten older recall fixtures sent the fact itself as the query. I reworded those queries so they keep their terms in a different order, and each test still checks what it checked before.

  • vp run check:changed origin/main passes.

Claude Opus 5.5 in Claude Code (T3 Code)

🤖 Generated with Claude Code

ScriptedAlchemy and others added 3 commits November 16, 2026 19:06
A brief that already carries a saved fact no longer spends one of recall's two
slots on it; the next match takes the slot. A fact counts as stated when at
least a tenth of its four-term runs appear in the message in order. Shared
names and scattered vocabulary still attach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ScriptedAlchemy ScriptedAlchemy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second-pass review: keeping this draft unmerged because the new suppression rule has a reproducible false-positive regression (inline). I compared the production recallForMessage implementation at main 0b41bb8 and this head using its default SQLite tokenizer. Questions and contradictory requests both lose the saved policy. I have not replaced this with a different heuristic: that would need semantic regression cases and a fresh evaluation of useful facts and replacement deliveries. The PR's aggregate replay results do not validate those cases, and I cannot reproduce the private judged corpus here.

relevance >= RECALL_MIN_COVERAGE &&
queryCoverage >= RECALL_MIN_MESSAGE_COVERAGE;
queryCoverage >= RECALL_MIN_MESSAGE_COVERAGE &&
!restates(queryRuns, termRuns(sequence));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve recall when the message questions or contradicts the saved fact

recallTermSequence removes negation and modality (never, not, must, should), and the tokenizer removes punctuation. Sharing a four-term run therefore does not establish that the message already states the saved claim.

I reproduced both cases through recallForMessage, using one fact with entities: [] and stats = { corpusSize: 1, docs: () => 1 }:

  • Saved: Cache keys must include tenant IDs. Message: Should cache keys include tenant IDs?
  • Saved: Never disable tenant authorization checks. Message: Disable tenant authorization checks.

Main returns the saved fact in both cases; this head returns []. These are situations where the stored rule is useful, but the new predicate hides it. An exact declarative restatement is suppressed too, so the current representation cannot distinguish the intended case from these regressions.

Please add these as regression cases and make suppression preserve the claim's polarity and whether it is being asserted or questioned. Re-evaluate useful-fact removals and the replacement deliveries before merging; a threshold adjustment alone cannot recover meaning already discarded by tokenization.

@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review November 17, 2026 04:41
@ScriptedAlchemy
ScriptedAlchemy merged commit ab95378 into main Nov 17, 2026
18 checks passed

@ScriptedAlchemy ScriptedAlchemy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question/negation restatement issue identified in my earlier review was still present in the merged head. The focused correction is now published in #145: complete-statement copy suppression preserves questions, contradictions, qualifications and entity-only overlap, and the domain passes the original query so truncation cannot hide trailing meaning. The long-message domain regression failed before its fix; all 65 selected tests now pass. CI for #145 must pass before it is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant